using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using TickSharp.Core.Interfaces;
using TickSharp.Core.Model;

namespace TickSharp.Core.Infrastructure.Serializers
{
    public class UserSerializer : ISerializer<User>
    {
        public IEnumerable<User> Deserialize(XElement elements)
        {
            return from e in elements.Elements()
                select new User
            {
                Id = int.Parse(e.Element("id").Value),
                Email = e.Element("email").Value,
                FirstName = e.Element("first_name").Value,
                LastName = e.Element("last_name").Value,                       
            };
        }
    }
}